home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2007 January
/
PCWorld_2007-01_cd.bin
/
v cisle
/
autoit
/
autoit-v3.2.0.1-setup.exe
/
Examples
/
Helpfile
/
DllStructGetPtr.au3
< prev
next >
Wrap
Text File
|
2006-06-17
|
2KB
|
62 lines
;example1
;get a window handle and use WinGetPos to get the windows' rectangle
$hwnd = WinGetHandle("")
$coor = WinGetPos($hwnd)
;create the struct
$rect = DllStructCreate("int;int;int;int")
;make the DllCall
DLLCall("user32.dll","int","GetWindowRect", _
"hwnd",$hwnd, _
"ptr",DllStructGetPtr($rect)) ; use DllStructGetPtr when calling DllCall
;get the returned rectangle
$l = DllStructGetData($rect,1)
$t = DllStructGetData($rect,2)
$r = DllStructGetData($rect,3)
$b = DllStructGetData($rect,4)
;free the struct
$rect = 0
;display the results of WinGetPos and the returned rectangle
MsgBox(0,"The Larry Test :)","WinGetPos(): (" & $coor[0] & "," & $coor[1] & _
") (" & $coor[2] + $coor[0] & "," & $coor[3] + $coor[1] & ")" & @CRLF & _
"GetWindowRect(): (" & $l & "," & $t & ") (" & $r & "," & $b & ")")
;example2
; DllStructGetPtr referencing an item
$a = DllStructCreate("int")
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif
$b = DllStructCreate("uint",DllStructGetPtr($a,1))
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif
$c = DllStructCreate("float",DllStructGetPtr($a,1))
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif
;set the data
DllStructSetData($a,1,-1)
;=========================================================
; Display the different data types of the same data
;=========================================================
MsgBox(0,"DllStruct",_
"int: " & DllStructGetData($a,1) & @CRLF & _
"uint: " & DllStructGetData($b,1) & @CRLF & _
"float: " & DllStructGetData($c,1) & @CRLF & _
"")
; release memory allocated
$a = 0